<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ include file="../../../common/taglib.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
		<sfa:mainTitle></sfa:mainTitle>
		<%@ include file="../../../common/meta.jsp"%>
		<style>
#title {
	display: block;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
	width: 125px;
}

.currentType {
	background-color: #E70102;
}
</style>
		<script type="text/javascript"
			src="${path}/script/JQueryRaty/js/jquery.raty.min.js">
</script>
		<script type="text/javascript" language="javascript">
/* tabpages */
function nTabs(tabObj, obj) {
	var tabList = document.getElementById(tabObj).getElementsByTagName("li");
	//alert(tabList.length);
	for (i = 0; i < tabList.length; i++) {
		if (tabList[i].id == obj.id) {
			document.getElementById(tabObj + "_title" + i).className = "current";
			i++;

		} else {
			document.getElementById(tabObj + "_title" + i).className = "";
		}
	}
}

$(function() {
	$(".finishapply").click(function() {
		var saletrantakeid = $(this).attr("val");
		url = "${path}/routine/lecturer/index/apply/" + saletrantakeid;
		art.dialog( {
			lock : true,
			content : '确定报名吗?',
			ok : function() {
				art.dialog( {
					id : "loading",
					lock : true,
					drag : false,
					resize : false,
					title : "正在报名..."
				});
				
				/*debugger;
					var joinCount = ${train.joinCount};
					var maxapplycont = ${train.maxapplycont};
					alert(joinCount);
					alert(maxapplycont);	*/
				$.post(url, null, function(result) {
					art.dialog( {
						id : 'loading'
					}).close();//关闭等待框
						//debugger;
						//alert(result); 
						result = '(' + result + ')';
						var obj = eval(result);
						if (obj.result == true) {
							art.dialog( {
								icon : "succeed",
								content :obj.message,
								lock : true,
								ok : function() {
									location.reload();
								}
							});
						} else {
							art.dialog( {
								icon : "error",
								content : obj.message,
								lock : true,
								ok : true
							});
						}

					});

				return true;
			},
			cancelVal : '关闭',
			cancel : true
		});
	});

	var point = 3;
	$(".finishgrade")
			.click(
					function() {
						var saleTrainTakeId = $(this).attr("val");
						art
								.dialog( {
									lock : true,
									content : "<div style='width:auto;height:100px;' >请评分:<div id='target'></div></div>",
									ok : function() {
										url = "${path}/routine/lecturer/index/grade";
										var data = {
											point : point,
											saleTrainTakeId : saleTrainTakeId
										}
										$.post(url, data, function(result) {
											art.dialog( {
												id : 'loading'
											}).close();//关闭等待框
												if (result == "true") {
													art.dialog( {
														icon : "succeed",
														content : "评分成功!",
														lock : true,
														ok : function() {
															location.reload();
														}
													});
												} else {
													art.dialog( {
														icon : "error",
														content : "评分失败!",
														lock : true,
														ok : true
													});
												}

											});
									},
									cancel : true,
									init : function() {
										point = 3;
										$('#target')
												.raty(
														{
															path : "${path}/script/JQueryRaty/img",
															start : 3,
															onClick : function(
																	score) {
																point = score;
															}
														});
									}
								});

					});
});
</script>
	</head>
	<body id="master">
		<sfa:mainHeader></sfa:mainHeader>
		<div class="webpart3 contentarea">
			<div class="webpart-head">
				<div class="webpart-head-item">
					参加培训
				</div>
			</div>
			<div class="webpart-main">
				<div class="webpart-main-item" style="padding-top: 12px;">
					<div class="search">
						<form method="get">
							<table width="100%" border="0" cellspacing="0" cellpadding="10"
								class="table_form">
								<tr>
									<td align="right">
										开始时间从：
									</td>
									<td>
										<input type="text" readonly="readonly" id="lecturerdate"
											name="lecturerdate" value="${lecturerdate}"
											onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"
											class="input-txt" />
										到：
										<input type="text" readonly="readonly" id="lecturerdate1"
											name="lecturerdate1" value="${lecturerdate1}"
											onclick="WdatePicker({dateFmt:'yyyy-MM-dd'})"
											class="input-txt" />
										<input type="submit" value="查 询" class="linkbtn2">
									</td>
									<td align="left">
									</td>
							</table>
						</form>
					</div>
					<div class="tabpage" id="tab">
						<ul>
							<li id="tab_title0" onclick="nTabs('tab',this);"
								<c:if test='${trainsType=="existing"}'>class="current"</c:if>>
								<a href="${path}/routine/lecturer/index/join/existing"> <span>现有培训</span>
								</a>
							</li>
							<li id="tab_title1" onclick="nTabs('tab',this);"
								<c:if test='${trainsType=="myjoin"}'>class="current"</c:if>>
								<a href="${path}/routine/lecturer/index/join/myjoin"><span>我参加的培训</span>
								</a>
							</li>
						</ul>
						<table cellpadding="0" cellspacing="0"
							class="dg_borderstyle trStyleTable" style="margin-top: 15px;">
							<tr>
								<th name="fixcol"><span>序号</span></th>  
								<th>
									培训开始时间
								</th>
								<th>
									培训名称
								</th>
								<th>
									培训讲师
								</th>
								<th>
									报名人数
								</th>
								<th>
									最大报名人数
								</th>
								<th>
									状态
								</th>
								<th>
									报名
								</th>
								<th>
									操作
								</th>
							</tr>
							<c:forEach items="${pagination.resultList}" var="train" varStatus="ind" >
								<tr>
									<td>${(pagination.page-1)*10+(ind.index+1)}</td> 

									<td align="center">
										<fmt:formatDate value="${train.trainstartdate}"
											pattern="yyyy-MM-dd HH:mm" />
									</td>
									<td align="center" width="100">
										<a id="title"
											href="${path}/routine/lecturer/index/joindetail/${train.saletrantakeid}" title="${train.trainitem}">${train.trainitem}</a>
									</td>
									<td align="center">
										${train.trainername}
									</td>
									<td align="center">
										${train.joinCount}
									</td>
									<td align="center">
										${train.maxapplycont}
									</td>
									<td align="center">
										${train.statusname}
									</td>
									<td align="center">
										${train.joinstatus}
									</td>
									<td align="center" width="10%"> 
										<c:if
											test='${train.trainstatus=="TRAINSTATUS_02" && train.joinStatus=="未报名" && train.joinCount <  train.maxapplycont}'>
											<a class="finishapply" href="javascript:void(0);"
												val="${train.saletrantakeid}">报名</a>
										</c:if>
										<c:if test='${train.maxapplycont <= train.joinCount && train.trainstatus=="TRAINSTATUS_02"}'>
											人数已满
										</c:if>
										<c:if
											test='${train.trainstatus=="TRAINSTATUS_05" && train.joinStatus=="已报名" && train.gradeStatus=="未评分"}'>
											<a class="finishgrade" href="javascript:void(0);"
												val="${train.saletrantakeid}">评分 </a>
										</c:if>

										<c:if
											test='${train.trainstatus=="TRAINSTATUS_05" && train.joinStatus=="已报名" && train.gradeStatus=="已评分"}'>
											<span>已评分</span>
										</c:if>
									</td>
								</tr>
							</c:forEach>
						</table>
						<div class="dg_pagerstyle">
							<div class="pageinfo">
								<c:if test="${not empty pagination.multiPage}">
							   第${pagination.page }页 | 共${pagination.totalPages }页/${pagination.totalRows }条记录
						</c:if>
							</div>
							<div class="pagebtn">
								${pagination.multiPage}
							</div>
						</div>
					</div>
				</div>
				<div class="webpart-foot">
					<div class="webpart-foot-item">
					</div>
				</div>
			</div>
		</div>
		<sfa:mainFooter></sfa:mainFooter>
	</body>
</html>
